package com.omaitec.log4j.mq.spring;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;

import org.apache.activemq.command.ActiveMQObjectMessage;

import com.omaitec.log4j.mq.expand.LoggingEventWrapper;

public class ConsumerListener1 implements MessageListener {

    @Override
    public void onMessage(Message message) {
	if (message instanceof ActiveMQObjectMessage) {
	    ActiveMQObjectMessage m = (ActiveMQObjectMessage) message;
	    try {
		Object o = m.getObject();
		if (o instanceof LoggingEventWrapper) {
		    LoggingEventWrapper w = (LoggingEventWrapper) o;
		    System.out.println("ConsumerListener1消息内容是："
			    + w.getMessage());
		} else {
		    System.out.println("ConsumerListener1消息内容是：" + message);
		}
	    } catch (JMSException e) {
		e.printStackTrace();
	    }
	} else {
	    System.out.println("ConsumerListener1消息内容是：" + message);
	}

    }

}
